﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using skhukb.BL;

namespace skhukb.Util
{
    public static class MyHtmlHelper
    {
        public static MvcHtmlString Link(this HtmlHelper html, string text, string url, string 스타일 = null, string 확인메시지 = null)
        {
            TagBuilder tag = new TagBuilder("a");
            tag.Attributes["href"] = url;
            tag.SetInnerText(text);
            tag.AddCssClass(스타일);
            if (확인메시지 != null) tag.Attributes[Consts.DATA_CONFIRM_MESSAGE] = 확인메시지;
            return new MvcHtmlString(tag.ToString());
        }

        public static MvcHtmlString AjaxLink(this HtmlHelper html, string text, string url, string 출력태그ID, string 스타일 = null, string 확인메시지 = null)
        {
            TagBuilder tag = new TagBuilder("a");
            tag.Attributes["href"] = url;
            tag.Attributes["data-ajax"] = "true";
            tag.Attributes["data-ajax-mode"] = "replace";
            tag.Attributes["data-ajax-update"] = "#" + 출력태그ID;
            tag.SetInnerText(text);
            tag.AddCssClass(스타일);
            if (확인메시지 != null) tag.Attributes[Consts.DATA_CONFIRM_MESSAGE] = 확인메시지;
            return new MvcHtmlString(tag.ToString());
        }

        public static string JS(this String s)
        {
            return HttpUtility.JavaScriptStringEncode(s);
        }
    }
}